<template>
	<jk-dialog
		v-model="showDialog"
		title="详情-纱种工艺"
		width="800px"
		:show-content-loading="showLoading"
		append-to-body
		:show-cancel-btn="false"
		:show-close-btn="true"
		:show-confirm-btn="false"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="ruleForm" :model="ruleForm" label-width="110px" :show-message="false">
			<el-row ref="box1">
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="编码" prop="code">
						<span class="read-only-2">{{ ruleForm.code }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="名称" prop="name">
						<span class="read-only-2">{{ ruleForm.name }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item class="margin-bottom-10" label="项目">
						<jk-table :data="ruleForm.varietyYarnSpecItemList" :height="dialogTableHeight - 20">
							<vxe-column title="编号" align="left" field="code" :min-width="100"></vxe-column>
							<vxe-column title="名称" align="left" field="name" :min-width="100"></vxe-column>
							<vxe-column title="排序" align="center" field="sortNum" :min-width="100"></vxe-column>
						</jk-table>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    import { spinVarietyYarnSpecGet } from '../../../api/technology/yarnSeedTechnology';

    export default {
        name: 'YarnSeedTechnology',
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataId: {
                type: [String, Number],
                default: ''
            }
        },
        mixins: [calHeight],
        data() {
            return {
                showDialog: false,
                showLoading: true,
                ruleForm: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                }
            },
            getDetailRequest() {
                this.showLoading = true;
                return spinVarietyYarnSpecGet({ id: this.dataId }).then(res => {
                    this.showLoading = false;
                    if (res.data.status === 200) {
                        const resData = res.data.res ? JSON.parse(JSON.stringify(res.data.res)) : {};
                        this.ruleForm = resData;
                    }
                });
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal && this.dataId) {
                    this.getDetailRequest();
                }
            }
        }
    };
</script>
